﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlSetUpTuyenDuong.ascx.cs" Inherits="UserControl_ControlSetUpTuyenDuong" %>
 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register assembly="DevExpress.Web.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPopupControl" tagprefix="dxpc" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPivotGrid" tagprefix="dxwpg" %>



<script type="text/javascript">

    var allCheckBoxSelector1 = '#<%=grvProduct.ClientID%> input[id*="CheckAll"]:checkbox';
    var checkBoxSelector1 = '#<%=grvProduct.ClientID%> input[id*="CheckApprove"]:checkbox';

    function ToggleCheckUncheckAllOptionAsNeeded1() {
        var totalCheckboxes = $(checkBoxSelector1),
         checkedCheckboxes = totalCheckboxes.filter(":checked"),
         noCheckboxesAreChecked = (checkedCheckboxes.length === 0),
         allCheckboxesAreChecked = (totalCheckboxes.length === checkedCheckboxes.length);

        $(allCheckBoxSelector1).attr('checked', allCheckboxesAreChecked);
    }



    var allCheckBoxSelector = '#<%=grvCust.ClientID%> input[id*="CheckAll"]:checkbox';
    var checkBoxSelector = '#<%=grvCust.ClientID%> input[id*="CheckApprove"]:checkbox';

    function ToggleCheckUncheckAllOptionAsNeeded() {
        var totalCheckboxes = $(checkBoxSelector),
         checkedCheckboxes = totalCheckboxes.filter(":checked"),
         noCheckboxesAreChecked = (checkedCheckboxes.length === 0),
         allCheckboxesAreChecked = (totalCheckboxes.length === checkedCheckboxes.length);

        $(allCheckBoxSelector).attr('checked', allCheckboxesAreChecked);
    }


    function pageLoad() {

        $(allCheckBoxSelector1).live('click', function () {
            $(checkBoxSelector1).attr('checked', $(this).is(':checked'));

            ToggleCheckUncheckAllOptionAsNeeded1();
        });

        $(checkBoxSelector1).live('click', ToggleCheckUncheckAllOptionAsNeeded);
        ToggleCheckUncheckAllOptionAsNeeded1();


        
        $(allCheckBoxSelector).live('click', function () {
            $(checkBoxSelector).attr('checked', $(this).is(':checked'));

            ToggleCheckUncheckAllOptionAsNeeded();
        });

        $(checkBoxSelector).live('click', ToggleCheckUncheckAllOptionAsNeeded);

        ToggleCheckUncheckAllOptionAsNeeded();


        $("#<%= LinkClearKH.ClientID %>").click(function () {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });
        $("#<%= LinkClearAllSetup.ClientID %>").click(function () {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });
        $("#<%= imgBtnAdd.ClientID %>").click(function () {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });
    $("#<%= btGetKH.ClientID %>").click(function () {

            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });

        });

    $("#<%= LinkSelectAll.ClientID %>").click(function () {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });
    $("#<%= btClearKH.ClientID %>").click(function () {
        $.blockUI({ css: {
            border: 'none',
            padding: '15px',
            backgroundColor: '#000',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: .5,
            color: '#fff'
        }
        });
    });
    

    $("#<%= btGetSP.ClientID %>").click(function () {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
    });
    $("#<%= btClearSP.ClientID %>").click(function () {
        $.blockUI({ css: {
            border: 'none',
            padding: '15px',
            backgroundColor: '#000',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: .5,
            color: '#fff'
        }
        });
});
$("#<%= BtnSave.ClientID %>").click(function () {
    $.blockUI({ css: {
        border: 'none',
        padding: '15px',
        backgroundColor: '#000',
        '-webkit-border-radius': '10px',
        '-moz-border-radius': '10px',
        opacity: .5,
        color: '#fff'
    }
    });
});

        $("#<%= imgBtnDelete.ClientID %>").click(function () {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args) {
            $.unblockUI();
        }
    }

</script>

 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

     <dxpc:ASPxPopupControl ID="MessageBoxUserGroup" PopupHorizontalAlign="WindowCenter"  PopupVerticalAlign="TopSides" Font-Bold="true" HeaderText="Chọn sản phẩm cho khách hàng" 
            runat="server" Width="600px" Modal="true" ShowPageScrollbarWhenModal="true" ShowCloseButton="true" CloseAction="CloseButton" >                
                <ContentCollection>
                    <dxpc:PopupControlContentControl ID="PopupControlContentControl4" runat="server" SupportsDisabledAttribute="True">
                       
                                    <!-- Content main-->
                                    <div class="direct_container_main">
                                        <div class="direct_container_form_right">
                                            <table border="0" width="100%">
                                            
                                                <tr>
                                                    <td colspan="2" align="center">
                                                       
                                                        <asp:Label ID="lblSelectSPFor" runat="server" Text=""></asp:Label>
                                                    </td>
                                                </tr>
                                                 <tr>
                                                <td width="10%" align="right"><p class="direct_label">Gam hàng</p></td>
                                                <td width="90%" align="left">
                                                        <asp:DropDownList AutoPostBack="true"
                                                                        onselectedindexchanged="DropGroup_SelectedIndexChanged" ID="DropGroup" runat="server">
                                                        </asp:DropDownList>
                                                </td>
                                                </tr>
                                                    <tr>
                                                <td width="10%" align="right"><p class="direct_label">Nhóm sản phẩm</p></td>
                                                <td width="90%" align="left">     
                                                        <asp:DropDownList ID="DropChannel" runat="server">
                                                        </asp:DropDownList>
                                                    <asp:Button ID="btGetSP" runat="server" CssClass="direct_bt_search" Text="Lấy thông tin" 
                                                        onclick="btGetSP_Click" />
                                                    <asp:Button ID="btClearSP" runat="server" CssClass="direct_bt_search" Text="Chọn" 
                                                        onclick="btClearSP_Click" />
                                                </td>
                                                </tr>
                                               <tr>
                                                    <td colspan="2">
                                                    <asp:GridView ID="grvProduct" runat="server" AutoGenerateColumns="False" 
                                         OnPageIndexChanging="grvProduct_PageIndexChanging" 
                                         PageSize="15" AllowPaging="true"
                                         DataKeyNames="itemkey" EnableModelValidation="True">
                                         <Columns>
                            <asp:TemplateField HeaderText="">
                                          <HeaderTemplate>
                    <asp:CheckBox ID="CheckAll" onclick="SelectCheckboxes(this,'grvCust');" runat="server"/>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="CheckApprove" runat="server" />
                </ItemTemplate>
                </asp:TemplateField>
                            <asp:TemplateField HeaderText="Stt">
                                <HeaderTemplate>
                                                                    STT
                                                                
                                         
                                </HeaderTemplate>
                            <ItemTemplate>
                                                                    <%# Container.DataItemIndex + 1 %>
                                                                
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="50px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="50px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Mã sản phẩm(SKU)"><HeaderTemplate>
                                                                    Mã mặt hàng(SKU)
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblitemkey" runat="server" Text='<%# Eval("itemkey")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Mô tả"><HeaderTemplate>
                                                                    Mô tả
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Gam hàng"><HeaderTemplate>
                                                                    Gam hàng
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblGroup" runat="server" Text='<%# Eval("Group")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Nhóm sản phẩm"><HeaderTemplate>
                                                                    Nhóm sản phẩm
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblChannel" runat="server" Text='<%# Eval("Channel")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
 <asp:TemplateField HeaderText="NPP"><HeaderTemplate>
                                                                    NPP
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblNPP" runat="server" Text='<%# Eval("NPP")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>




</Columns>
</asp:GridView>
                                                    </td>
                                               </tr>
                                                
                                               
                                            </table>
                                        </div>
                                    </div>
                                    <!-- EndContent main-->
                               
                           
                                     
                                                
                    </dxpc:PopupControlContentControl>                
                </ContentCollection>
            </dxpc:ASPxPopupControl> 
     <dxpc:ASPxPopupControl ID="ASPxPopupDuplicated" PopupHorizontalAlign="WindowCenter"  PopupVerticalAlign="TopSides" Font-Bold="true" HeaderText="Thông báo" 
            runat="server" Width="600px" Modal="true" ShowPageScrollbarWhenModal="true" ShowCloseButton="true" CloseAction="CloseButton" >                
                <ContentCollection>
                    <dxpc:PopupControlContentControl ID="PopupControlContentControl2" runat="server" SupportsDisabledAttribute="True">
                       
                                    <!-- Content main-->
                                    <div class="direct_container_main">
                                        <div class="direct_container_form_right">
                                            <table border="0" width="100%">
                                            
                                                <tr>
                                                    <td colspan="2" align="center">
                                                       
                                                        <asp:Label ID="Label1" runat="server" Text="Đã có trình dược viên khác được phân tuyến cho khách hàng và sản phẩm này"></asp:Label>
                                                    </td>
                                                </tr>
                                                 <tr>
                                                    <td colspan="2">
                                                        <asp:LinkButton ID="LinkRemove" onclick="LinkRemove_Click" runat="server">Click vào đây để loại bỏ</asp:LinkButton>
                                                        
                                                    </td>
                                                </tr>
                                                  
                                               <tr>
                                                    <td colspan="2">
                                                    <asp:GridView ID="grvDup" runat="server" AutoGenerateColumns="False" 
                                        
                                         EnableModelValidation="True">
                                         <Columns>
                           
                            <asp:TemplateField HeaderText="Stt">
                                <HeaderTemplate>
                                                                    STT
                                                                
                                         
                                </HeaderTemplate>
                            <ItemTemplate>
                                                                    <%# Container.DataItemIndex + 1 %>
                                                                
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="50px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="50px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Trình dược viên"><HeaderTemplate>
                                                                    Trình dược viên
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblsalesp_name" runat="server" Text='<%# Eval("salesp_name")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="250px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="250px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Khách hàng"><HeaderTemplate>
                                                                    Khách hàng
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblcustomer_name" runat="server" Text='<%# Eval("customer_name")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="250px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="250px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Địa chỉ"><HeaderTemplate>
                                                                   Địa chỉ
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lbladdress" runat="server" Text='<%# Eval("address")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
                            <asp:TemplateField HeaderText="Sản phẩm"><HeaderTemplate>
                                                                   Mặt hàng
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lbldescription" runat="server" Text='<%# Eval("description")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>




</Columns>
</asp:GridView>
                                                    </td>
                                               </tr>
                                                
                                               
                                            </table>
                                        </div>
                                    </div>
                                    <!-- EndContent main-->
                               
                           
                                     
                                                
                    </dxpc:PopupControlContentControl>                
                </ContentCollection>
            </dxpc:ASPxPopupControl> 
      <div class="direct_container_right_titletop direct_colleft">
                     Phân tuyến cho trình dược viên
                </div>
                
                <!-- Button chuc nang-->
                <div class="direct_menu_report_page direct_colleft">
                    <asp:ImageButton ID="imgBtnAdd" ToolTip="Tạo mới mghiệp vụ phân tuyến cho TDV" onclick="imgBtnAdd_Click" CausesValidation="false" ImageUrl="~/Images/add.png" Width="32px" Height="32px" runat="server" />
                    <%--<asp:ImageButton ID="imgBtnSave" ToolTip="Mapping 02 thông tin khách hàng" onclick="imgBtnSave_Click" ImageUrl="~/Images/save.png" Width="32px" Height="32px" runat="server" />--%>
                    <asp:ImageButton ID="imgBtnDelete" ToolTip="Xóa nghiệp vụ" onclick="imgBtnDelete_Click" ImageUrl="~/Images/delete.png" Width="32px" Height="32px" runat="server" />
                   
                </div>
                <!-- End Button chuc nang-->
                <div class="clear"></div>
                 <hr />

                <!-- End Button chuc nang-->
     <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" 
            BackColor="#CCFFFF" Font-Names="Arial" 
            Width="100%">
             <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="1.Chọn TDV" TabIndex="0">
                 <ContentTemplate>
                     <div class="direct_container_main">
                    <div class="direct_container_form_right">
                        <table border="0" width="100%">
                         <tr>
                            <td colspan="2">
                               Chọn trình dược viên để phân tuyến
                            </td>
                        </tr>
                        

                             <tr>
                            <td colspan="2">
                            <asp:GridView ID="grvTDV" runat="server" AutoGenerateColumns="False" 
                                        onrowcommand="grvTDV_RowCommand" OnPageIndexChanging="grvTDV_PageIndexChanging" 
                                         PageSize="15" AllowPaging="true"
                                         DataKeyNames="salesp_key" EnableModelValidation="True">
                                         <Columns>
                            <asp:TemplateField HeaderText="Stt">
                                <HeaderTemplate>
                                                                    STT
                                                                
                                         
                                </HeaderTemplate>
                            <ItemTemplate>
                                                                    <%# Container.DataItemIndex + 1 %>
                                                                
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="50px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Mã TDV"><HeaderTemplate>
                                                                   Mã TDV
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblsalesp_key" runat="server" Text='<%# Eval("salesp_key")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="100px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tên TDV"><HeaderTemplate>
                                                                   Tên TDV
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblsalesp_name" runat="server" Text='<%# Eval("salesp_name")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Cấp bậc"><HeaderTemplate>
                                                                   Cấp bậc
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblCapBac" runat="server" Text='<%# Eval("CapBac")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tuyến trên"><HeaderTemplate>
                                                                   Báo cáo cho
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblRecommender" runat="server" Text='<%# Eval("Recommender")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="250px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="250px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Cấp bậc tuyến trên"><HeaderTemplate>
                                                                  Cấp bậc tuyến trên
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblCapBacRecommender" runat="server" Text='<%# Eval("CapBacTuyenTren")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Đã phân tuyến"><HeaderTemplate>
                                                                  Đã phân tuyến
                                                                
</HeaderTemplate>
<ItemTemplate>
            <asp:CheckBox ID="chIsSet" Enabled="false" runat="server" Checked='<%# Eval("isSet")%>' />                                                  
                                                              
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="100px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="100px" />
</asp:TemplateField>
<asp:TemplateField>
                                                                 <ItemTemplate>
                                                                    <asp:ImageButton ID="imgBtnChon" runat="server" CausesValidation="False" 
                                                                    CommandName="chon" Height="20px" ImageUrl="~/Images/check.png" />
                                                                </ItemTemplate>
                                                                <ControlStyle BackColor="White" BorderColor="White" />
                                                                <FooterStyle BackColor="White" BorderColor="White" />
                                                                <HeaderStyle BackColor="White" BorderColor="White" />
                                                                <ItemStyle BackColor="White" BorderColor="White" />
                                                            </asp:TemplateField>
</Columns>
</asp:GridView>
                            </td>
                           
                        </tr>
                        
                        
                      
                        
                         
                       
                        </table>
                    </div>
                    
                    </div>
                 </ContentTemplate>
            </cc1:TabPanel>
             <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="2.Chọn khách hàng" TabIndex="1">
                <ContentTemplate>
                     <div class="direct_container_main">
                        <div class="direct_container_form_right">
                            <table border="0" width="100%">
                                     <tr>
                                         <td colspan="2">
                                                 Chọn khách hàng cho trình dược viên 
                                             <asp:Label ID="lblInforTDV" runat="server" Text=""></asp:Label>
                                        </td>
                                     </tr> 
                                      <tr>
                             <td width="10%" align="right"><p class="direct_label">Tỉnh/thành</p></td>
                            <td width="90%" align="left"> 
                                <asp:DropDownList  AutoPostBack="true"
                                            onselectedindexchanged="DropProvice_SelectedIndexChanged" ID="DropProvice" runat="server">
                                </asp:DropDownList>
                                <asp:DropDownList ID="DropTown" runat="server">
                                </asp:DropDownList>
                                <asp:CheckBox ID="chNotSet" Text="Chưa được phân tuyến" Checked="false" runat="server" />
                                <asp:Button ID="btGetKH" runat="server" CssClass="direct_bt_search" Text="Lấy thông tin" 
                                        onclick="btGetKH_Click" />
                                <asp:Button ID="btClearKH" runat="server" CssClass="direct_bt_search" Text="Chọn" 
                                        onclick="btClearKH_Click" />
                            </td>
                           
                        </tr> 
                                <tr>
                       <td colspan="2">
                             <asp:GridView ID="grvCust" runat="server" AutoGenerateColumns="False" 
                                        onrowcommand="grvCust_RowCommand" OnPageIndexChanging="grvCust_PageIndexChanging" 
                                         PageSize="15" AllowPaging="true"
                                         DataKeyNames="CustID" EnableModelValidation="True">
                                         <Columns>
                                         <asp:TemplateField HeaderText="">
                <HeaderTemplate>
                    <asp:CheckBox ID="CheckAll" runat="server"/>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="CheckApprove" runat="server" />
                </ItemTemplate>
            
                        
            </asp:TemplateField>
           
                            <asp:TemplateField HeaderText="Stt">
                                <HeaderTemplate>
                                                                    STT
                                                                
                                         
                                </HeaderTemplate>
                            <ItemTemplate>
                                                                    <%# Container.DataItemIndex + 1 %>
                                                                
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="50px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Mã khách hàng"><HeaderTemplate>
                                                                    Mã khách hàng
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblCustID" runat="server" Text='<%# Eval("CustID")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tên khách hàng"><HeaderTemplate>
                                                                    Tên khách hàng
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblCustName" runat="server" Text='<%# Eval("Customer_name")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Địa chỉ"><HeaderTemplate>
                                                                    Địa chỉ
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblDiaChi" runat="server" Text='<%# Eval("DiaChi")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tỉnh/Thành"><HeaderTemplate>
                                                                    Tỉnh/Thành
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblTinhThanh" runat="server" Text='<%# Eval("ProvinceCode")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Quận/Huyện"><HeaderTemplate>
                                                                    Quận/Huyện
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblTown" runat="server" Text='<%# Eval("Town")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Nhà phân phối"><HeaderTemplate>
                                                                    Nhà phân phối
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblNPP" runat="server" Text='<%# Eval("NPP")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>

</Columns>
</asp:GridView>
                       </td>
                       </tr>  
                            </table>
                        </div>
                    </div>
                </ContentTemplate>
            </cc1:TabPanel>
             <cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="3.Chọn mặt hàng" TabIndex="2">
                <ContentTemplate>
                     <div class="direct_container_main">
                        <div class="direct_container_form_right">
                            <table border="0" width="100%">
                                           
                                        <tr>
                                            <td colspan="2">
                                                <asp:LinkButton onclick="LinkSelectAll_Click" ID="LinkSelectAll" runat="server">Click vào đây để chọn mặt hàng cho tất cả khách hàng này</asp:LinkButton>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <asp:LinkButton onclick="LinkClearKH_Click" ID="LinkClearKH" runat="server">Click vào đây để xóa tất cả khách hàng bên dưới</asp:LinkButton>
                                            </td>
                                        </tr>
                                        <tr>
                            <td colspan="2">
                            <asp:GridView ID="grvSet" runat="server" AutoGenerateColumns="False" 
                                        onrowcommand="grvSet_RowCommand" OnPageIndexChanging="grvSet_PageIndexChanging" 
                                        onrowdeleting="grvSet_RowDeleting"
                                         PageSize="15" AllowPaging="true"
                                          EnableModelValidation="True">
                                         <Columns>
                            <asp:TemplateField HeaderText="Stt">
                                <HeaderTemplate>
                                                                    STT
                                                                
                                         
                                </HeaderTemplate>
                            <ItemTemplate>
                                                                    <%# Container.DataItemIndex + 1 %>
                                                                
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="50px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="50px" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Mã khách hàng"><HeaderTemplate>
                                                                    Mã khách hàng
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblcustid" runat="server" Text='<%# Eval("custid")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="100px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tên khách hàng"><HeaderTemplate>
                                                                    Tên khách hàng
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblcustomer_name" runat="server" Text='<%# Eval("customer_name")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Địa chỉ"><HeaderTemplate>
                                                                    Địa chỉ
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <%# Eval("address")%>   
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tỉnh/thành"><HeaderTemplate>
                                                                    Tỉnh/thành
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <%# Eval("ProvinceCode")%>                                    
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Quận/Huyện"><HeaderTemplate>
                                                                    Quận/Huyện
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <%# Eval("QuanHuyen")%>                                 
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:CommandField  ButtonType="Image" DeleteText="Xóa" 
                                                                DeleteImageUrl="~/images/delete.png" CausesValidation="False" HeaderText="Xóa" 
                                                                 ShowDeleteButton="True" >
<ControlStyle Height="25px" Width="25px" />

<ItemStyle Height="25px" Width="25px" />
</asp:CommandField>
<asp:TemplateField>
                                                                 <ItemTemplate>
                                                                    <asp:ImageButton ID="imgBtnChon" runat="server" CausesValidation="False" 
                                                                    CommandName="chon" Height="20px" ImageUrl="~/Images/check.png" />
                                                                </ItemTemplate>
                                                                <ControlStyle BackColor="White" BorderColor="White" />
                                                                <FooterStyle BackColor="White" BorderColor="White" />
                                                                <HeaderStyle BackColor="White" BorderColor="White" />
                                                                <ItemStyle BackColor="White" BorderColor="White" />
                                                            </asp:TemplateField>
</Columns>
</asp:GridView>
                            </td>
                       </tr>
                            </table>
                        </div>
                    </div>
                </ContentTemplate>
            </cc1:TabPanel>
             <cc1:TabPanel ID="TabPanel4" runat="server" HeaderText="4.Kết quả" TabIndex="3">
                <ContentTemplate>
                     <div class="direct_container_main">
                        <div class="direct_container_form_right">
                            <table border="0" width="100%">
                                   <tr>
                                   <td colspan="2">Kết quả phân tuyến cho TDV<asp:LinkButton onclick="LinkClearAllSetup_Click" ID="LinkClearAllSetup" runat="server">,hoặc click vào đây nếu bạn muốn xóa hết!</asp:LinkButton></td>
                                   </tr>    
                                   <tr>
                                   <td colspan="2">
                                   <asp:GridView ID="grvResult" runat="server" AutoGenerateColumns="False" 
                                         OnPageIndexChanging="grvResult_PageIndexChanging" 
                                        onrowdeleting="grvResult_RowDeleting"
                                         PageSize="15" AllowPaging="true"
                                          EnableModelValidation="True">
                                         <Columns>
                            <asp:TemplateField HeaderText="Stt">
                                <HeaderTemplate>
                                                                    STT
                                                                
                                         
                                </HeaderTemplate>
                            <ItemTemplate>
                                                                    <%# Container.DataItemIndex + 1 %>
                                                                
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="50px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Mã mặt hàng(SKU)"><HeaderTemplate>
                                                                    Mã mặt hàng(SKU)
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblitemkey" runat="server" Text='<%# Eval("itemkey")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="100px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tên mặt hàng(SKU)"><HeaderTemplate>
                                                                    Tên mặt hàng(SKU)
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="100px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="100px" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Mã khách hàng"><HeaderTemplate>
                                                                    Mã khách hàng
                                                                
</HeaderTemplate>
<ItemTemplate>
                                                                   
                    <asp:Label ID="lblcustid" runat="server" Text='<%# Eval("custid")%>'></asp:Label>                                             
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="100px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tên khách hàng"><HeaderTemplate>
                                                                    Tên khách hàng
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <asp:Label ID="lblcustomer_name" runat="server" Text='<%# Eval("customer_name")%>'></asp:Label>                                               
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Địa chỉ"><HeaderTemplate>
                                                                    Địa chỉ
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <%# Eval("address")%>   
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="200px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tỉnh/thành"><HeaderTemplate>
                                                                    Tỉnh/thành
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <%# Eval("ProvinceCode")%>                                    
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Quận/Huyện"><HeaderTemplate>
                                                                    Quận/Huyện
</HeaderTemplate>
<ItemTemplate>
                                                                  
                  <%# Eval("QuanHuyen")%>                                 
</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" Width="150px" />

<ItemStyle Height="40px" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
<asp:CommandField  ButtonType="Image" DeleteText="Xóa" 
                                                                DeleteImageUrl="~/images/delete.png" CausesValidation="False" HeaderText="Xóa" 
                                                                 ShowDeleteButton="True" >
<ControlStyle Height="25px" Width="25px" />

<ItemStyle Height="25px" Width="25px" />
</asp:CommandField>

</Columns>
</asp:GridView>
                                   </td>
                                   </tr>
                            </table>
                        </div>
                    </div>
                </ContentTemplate>
            </cc1:TabPanel>
             <cc1:TabPanel ID="TabPanel5" runat="server" HeaderText="Sơ đồ" TabIndex="4">
                <ContentTemplate>
                 <table border="0" width="100%">
                                   <tr>
                                   <td colspan="2">
                                    <asp:Button ID="BtnSave" runat="server" CssClass="direct_bt_search" Text="Lưu thông tin" 
                                        onclick="BtnSave_Click" />
                                   </td>
                                   </tr>    
                                   <tr>
                                   <td colspan="2">
                     <dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1"  runat="server">
                 <Fields>
                        <dxwpg:PivotGridField ID="Pivotsalesp_key" Area="RowArea"  AreaIndex="0" 
                         Caption="Trình dược viên" FieldName="salesp_key">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="PivotProvinceCode" Area="RowArea"  AreaIndex="1" 
                         Caption="Tỉnh/Thành" FieldName="ProvinceCode">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="PivotTownCode" Area="RowArea"  AreaIndex="2" 
                         Caption="Quận/Huyện" FieldName="QuanHuyen">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="Pivotcustomername" Area="RowArea"  AreaIndex="3" 
                         Caption="Khách hàng" FieldName="customername">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="Pivotaddress" Area="RowArea"  AreaIndex="4" 
                         Caption="Địa chỉ" FieldName="address">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="PivotNPPKH" Area="RowArea"  AreaIndex="5" 
                         Caption="NPP của khách hàng" FieldName="NPPKH">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="Pivotitemkey" Area="RowArea"  AreaIndex="7" 
                         Caption="Mặt hàng" FieldName="itemkey">
                        </dxwpg:PivotGridField>
                         <dxwpg:PivotGridField ID="PivotNPPSP" Area="RowArea"  AreaIndex="8" 
                         Caption="NPP của sản phẩm" FieldName="NPPSP">
                        </dxwpg:PivotGridField>
                    </Fields>
                    <OptionsPager Visible="False">
                    </OptionsPager>
                    <OptionsView  ShowColumnGrandTotals="True" ShowRowGrandTotals="True" />
                    </dxwpg:ASPxPivotGrid>
                    </td>
                    </tr>
                    </table>
                 </ContentTemplate>
            </cc1:TabPanel>
    </cc1:TabContainer>
     <dxpc:ASPxPopupControl ID="MessageBox" PopupHorizontalAlign="WindowCenter"  PopupVerticalAlign="WindowCenter" Font-Bold="true" HeaderText="DRM-S" runat="server" Height="91px" 
        Width="601px">
        <ContentCollection>
<dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server" SupportsDisabledAttribute="True"></dxpc:PopupControlContentControl>
</ContentCollection>
    </dxpc:ASPxPopupControl>
    </ContentTemplate>
</asp:UpdatePanel>
